package com.infosys.cabplanning.common.exception;

public abstract class AppBaseException extends Exception {

	private static final long serialVersionUID = 1L;
	private ExceptionType exceptionType;
	private ExceptionSiverity siverity;

	public ExceptionSiverity getSiverity() {
		return siverity;
	}

	public void setSiverity(ExceptionSiverity siverity) {
		this.siverity = siverity;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	public AppBaseException() {
		// TODO Auto-generated constructor stub
	}

	public AppBaseException(String message) {
		super(message);
		// TODO Auto-generated constructor stub
	}

	public AppBaseException(Throwable throwable) {
		super(throwable);
		// TODO Auto-generated constructor stub
	}

	public AppBaseException(String message, Throwable throwable) {
		super(message, throwable);
		// TODO Auto-generated constructor stub
	}

	public static enum ExceptionType {
		
		WEB_TIER_EXCEPTION("WEB_TIER_EXCEPTION"),
		BUSINESS_TIER_EXCEPTION("BUSINESS_TIER_EXCEPTION"),
		SERVICE_TIER_EXCEPTION("SERVICE_TIER_EXCEPTION"),
		DATA_TIER_EXCEPTION("DATA_TIER_EXCEPTION");
		
		private String exceptionType;

		public void setExceptionType(String exceptionType) {
			this.exceptionType = exceptionType;
		}

		public String getExceptionType() {
			return exceptionType;
		}
		
		ExceptionType(String name) {
			setExceptionType(name);
		}
		
		public String value() {
			return this.name();
		}
	}
	
	public static enum ExceptionSiverity {
		
		FATAL,
		NORMAL,
		RUNTIME
	}
	
	public abstract ExceptionType getException();
	
	public String toJSONString() {
		AppExceptionMessage appExceptionMessage = new AppExceptionMessage("101", this.getMessage(), this.getExceptionType().name());
		String exceptionMessage = appExceptionMessage.exceptionMessage();
		
		return exceptionMessage;
	}

	public void setExceptionType(ExceptionType exceptionType) {
		this.exceptionType = exceptionType;
	}

	public ExceptionType getExceptionType() {
		return exceptionType;
	}
	
}
